﻿using System;
using System.Runtime.Serialization;
using System.Text;

namespace PDO.DataPersistence.Core
{

    [global::System.Serializable]
    public class PersistableDataObjectException : DataObjectsBaseException
    {
        //
        // For guidelines regarding the creation of new exception types, see
        //    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
        // and
        //    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
        //

        public PersistableDataObjectException() { }
        public PersistableDataObjectException(string message) : base(message) { }
        public PersistableDataObjectException(string message, Exception inner) : base(message, inner) { }

        protected PersistableDataObjectException(SerializationInfo info, StreamingContext context)
            : base(info, context) { }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder(base.ToString());
            
            if(InnerException != null)
            {
                sb.AppendLine(" Inner exception was:");
                sb.AppendLine(InnerException.ToString());
            }
            return sb.ToString();
        }
    }
}
